fix: remove the auth_zones lock and count up/down queries in a common way #1160
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The lock field in the auth_zones struct is used only to protect the up/down query counters. My understanding is that the auth_zones struct is only constructed when there are no other threads, so there are no possibilities for concurrent access. However, concurrent modifications still occur in auth_zones.c, specifically during query counting. By adopting a common approach to tracking up/down queries, similar to that used for other server statistics, we can simplify the codebase and eliminate the need for locking mechanisms.
I benchmarked the performance of this patch using the following configuration to effectively disable cache:
...
msg-cache-size: 2b
msg-cache-slabs: 1
rrset-cache-size: 2b
rrset-cache-slabs: 1
key-cache-size: 2b
key-cache-slabs: 1
neg-cache-size: 2b
...
Results:
Before
Read 9M.qerires, got 9000000 queries
qps: 137430
...
qps: 137043
overall time: 15.0001 sec
0(NOERROR): 2070494 replies
average qps: 138032
After
Read 9M.qerires, got 9000000 queries
qps: 159759
qps: 161599
...
qps: 166993
qps: 157685
overall time: 15 sec
0(NOERROR): 2451661 replies
average qps: 163444